package Common;

import java.sql.*;


public class SQL {
	
	Connection conn;
	
	public SQL(String url, String id, String passwd)
	{
		try
		{
			Class.forName("com.mysql.jdbc.Driver").newInstance();
		}
		catch (Exception e)
		{
			e.printStackTrace();
			//Runtime.getRuntime().exit(0);
		}
		
		try{
			conn = DriverManager.getConnection("jdbc:mysql://" + url + "?autoReconnect=true&initialTimeout=0", id, passwd);
			
		} catch(SQLException ex)
		{
			// handle any errors
			System.out.println("SQLException: " + ex.getMessage());
			System.out.println("SQLState: " + ex.getSQLState());
			System.out.println("VendorError: " + ex.getErrorCode());
		}
	}
	
	public void SQL_close()
	{
		try {
			conn.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		conn = null;
	}

}
